/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.Rit;
import org.hibernate.Session;
import org.hibernate.Transaction;
import persistence.SessionManager;

/**
 *
 * @author Johan
 */
public class RitEditController extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        int ritId = Integer.parseInt(request.getParameter("id"));

        Session session = null;
        session = SessionManager.openSession();

        Transaction tx = session.beginTransaction();
        Rit rit = (Rit) session.load(Rit.class, new Integer(ritId));

        request.setAttribute("rit", rit);

        String address = "/ritToevoegenEditten.jsp";
        RequestDispatcher dispatcher = request.getRequestDispatcher(address);
        dispatcher.forward(request, response);
        
         session.close();
    }
}
